package com.effectiv.gooruda.rest.service.api;

import java.util.Map;

import lombok.Getter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;

import com.effectiv.gooruda.rest.domain.Session;
import com.effectiv.gooruda.rest.domain.User;
import com.effectiv.gooruda.rest.ext.SecurityContextHolder;

public abstract class SessionService {
	
	private final String COLLECTION_BASE = "c_app_session_";
	
	@Getter
	@Autowired
	private MongoTemplate template;
	
	protected String getCollection(){
		return COLLECTION_BASE + SecurityContextHolder.get().getId();
	}
	
	public abstract Map<String,String> getAttributes(String sessionId);
	public abstract Object getAttribute(String sessionId, String key);
	
	public abstract Session findSessionByUser(String userName);
	public abstract Session create(String userName);
	public abstract Session create(User user);
	
	public abstract void invalidate(String sessionId);
	public abstract Session removeAllAttributes(String sessionId);
	public abstract Session removeAttribute(String sessionId, String key);
	
	public abstract Session setAttribute(String sessionId, String key, String value);
}
